using HCore.IOC.Beans.Factory.Attribute.Attr;
using HCore.IOC.Context.Event.Attr;
using HCore.IOC.Context.Stereotype;
using HCore.Tests.Runtime.ShootingEditor2D.Scripts.Support.CommandQuery;
using HCore.Tests.Runtime.ShootingEditor2D.Scripts.System.GunSystem;

namespace HCore.Tests.Runtime.ShootingEditor2D.Scripts.Command
{
    /// <summary>
    ///     补给站，填满所有枪的弹夹
    /// </summary>
    public class FullBulletCommand : ICommand
    {
    }

    [Component]
    public class FullBulletCommandHandler
    {
        [Autowired] private IGunSystem mGunSystem;

        [EventListener]
        public void ExecuteCommand(FullBulletCommand command)
        {
            mGunSystem.CurrentGun.BulletCountInGun.Value = mGunSystem.CurrentGunConfigItem.BulletMaxCount;
            foreach (var gunInfo in mGunSystem.GunInfos)
            {
                var bulletMax = mGunSystem.GetGunConfigByName(gunInfo.Name.Value).BulletMaxCount;
                gunInfo.BulletCountInGun.Value = bulletMax;
            }
        }
    }
}